package java115.Thread;
//查看线程的状态2
public class ThreadDemo2 {
    public static void main(String[] args) {
        final Object obj = new Object();
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized(obj) {
                    while(true) {
                        try {
                            //Thread.sleep(1000);
                            obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace(); 
                        }
                    }
                }
            }
        },"t1");
        t1.start();
         
        Thread t2 = new Thread(new Runnable(){
            @Override
            public void run() {
                synchronized(obj) {
                    System.out.println("t2线程执行");
                }
            }
        },"t2");
        t2.start();
    }
}
